<!DOCTYPE html>
<html lang="en" ;>
<head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" href="/static/component/pear/css/pear.css" />
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
<form class="layui-form" action="">
    <div class="layui-form-item" style="margin-top: 50px">
        <div class="layui-inline">
            <label class="layui-form-label">任务编号:</label>
            <div class="layui-input-inline">
                <input type="text" name="taskId" id="RenWuBiAnHao" lay-verify="title" autocomplete="off" placeholder="请输入任务编号" class="layui-input">
            </div>
            <label class="layui-form-label">线路编号：</label>
            <div class="layui-input-inline">
                <input type="text" name="lineCode" id="XianLu" lay-verify="title" autocomplete="off" placeholder="请输入线路编号" class="layui-input">
            </div>
            <label class="layui-form-label">杆塔编号：</label>
            <div class="layui-input-inline">
                <input type="text" name="poleCode" id="GanTa" lay-verify="title" autocomplete="off" placeholder="请输入杆塔编号" class="layui-input">
            </div>
            <label class="layui-form-label">发现人：</label>
            <div class="layui-input-inline">
                <input type="text" name="discovererName" id="FAXianRen" lay-verify="title" autocomplete="off" placeholder="发现人" class="layui-input">
            </div>
            <div class="layui-input-inline" style="">
                <button type="button" class="layui-btn layui-btn-normal zengJiQxMessage"  lay-submit lay-filter="user-query">
                    查询
                </button>
            </div>
        </div>
        <div class="layui-inline" style="margin-top: 20px">
            <label class="layui-form-label">缺陷类型:</label>
            <div class="layui-input-inline" >
                <select name="bugType" lay-verify="service" id="service">
                    <option value="0">--请选择--</option>
                </select>
            </div>
            <label class="layui-form-label">缺陷级别：</label>
            <div class="layui-input-inline" >
                <select name="bugLevel" lay-verify="service2" id="service2">
                    <option value="0">--请选择--</option>
                </select>
            </div>
            <label class="layui-form-label" >开始：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input"   placeholder="" name="kaishi" id="kaishi">
            </div>
            <label class="layui-form-label">结束：</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input"   placeholder="" name="jeiShu" id="jeiShu">
            </div>
        </div>
    </div>
</form>
<script type="text/html" id="user-bar1">
        <button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit"><i class="layui-icon layui-icon-ok-circle"></i></button>
</script>
<div class="layui-card">
    <div class="layui-card-body">
        <table id="user-table" lay-filter="user-table"></table>
    </div>
</div>
<script type="text/html" id="user-bar">
    <div class="layui-input-inline" >
        <select name="22" lay-verify="service3" id="service3" class="service3">
            <option value="0">--请选择--</option>
        </select>
    </div>
</script>
<script type="text/html" id="user-bar2">
    <div class="layui-input-inline" >
        <select name="22" lay-verify="service4" id="service4" class="service3">
            <option value="0">--请选择--</option>
        </select>
    </div>
</script>
<script src="/static/component/layui/layui.js"></script>
<script src="/static/component/pear/pear.js"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use(['table', 'form', 'jquery','drawer','dropdown',"laydate"], function() {
        let table = layui.table;
        let form = layui.form;
        let $ = layui.jquery;
        let drawer = layui.drawer;
        let dropdown = layui.dropdown;
        let laydate=layui.laydate;
        let MODULE_PATH = "/system/user/";
        laydate.render({
            elem: '#kaishi'
        });
        laydate.render({
            elem: '#jeiShu'
        });
        // cols 格式
        let cols = [
            [
                {
                    title: 'id',
                    field: 'id',
                    align: 'center',
                    width: 100
                },
                {
                    title: '任务编号',
                    field: 'taskId',
                    align: 'center',
                    width: 100
                },
                {   title: '线路编号',
                    field: 'lineCode',
                    align: 'center'
                },
                {   title: '杆塔编号',
                    field: 'poleCode',
                    align: 'center',
                    width: 80,
                },
                {   title: '缺陷类型',
                    field: 'bugTypeName',
                    align: 'center'
                },
                {   title: '缺陷描述',
                    field: 'bugDesc',
                    align: 'center'
                },
                {   title: '发现时间',
                    field: 'discoverTime',
                    align: 'center',
                },
                {   title: '发现人员',
                    field: 'discovererName',
                    align: 'center',
                    width: 170
                },
                {   title: '缺陷级别',
                    field: 'bugLevelName',
                    toolbar: '#user-bar2',
                    align: 'center',
                    width: 170
                },
                {   title: '操作',
                    toolbar: '#user-bar1',
                    align: 'center',
                    width: 170
                }
            ]
        ]
        table.render({
            elem:'#user-table',
            url:'/QuXianGuAnLi/quXianDengJiQuRen',
            page: true,
            cols: cols,
            skin: 'line',
            toolbar: '#user-toolbar',
            defaultToolbar: [{
                layEvent: 'refresh',
                icon: 'layui-icon-refresh',
            }, 'filter', 'print', 'exports'],
            page:{
                limit:3,
                limits:[3,6,9]
            },
            done: function (res) {
                for (var i = 0; i < res.data.length; i++) {
                    // if (res.data[i].id == "5" || res.data[i].id == "8") {
                    // 	$("#more" + res.data[i].id).hide();
                    // 	continue;
                    // }
                    dropdown.suite("#more" + res.data[i].id, {
                        align:'left',
                        data: res.data[i],
                        templateMenu: "moreTool",
                    });
                }
                $(".layui-table-body, .layui-table-box, .layui-table-cell").css('overflow', 'visible');
                $.ajax({
                    url:"/XunJianZhiXing/ChaQueJi",
                    dataType: 'json',
                    success: function(data) {
                        if (data!== null) {
                            $(".service3").empty();
                            $(".service3").append(new Option("--请选择--","0"));
                            $.each(data, function(index, item) {
                                $('.service3').append(new Option(item.configName,item.id));
                            });
                        } else {
                            $(".service3").append(new Option("暂无数据","0"));
                        }
                        //重新渲染
                        form.render("select");
                    }
                })
            }
        });
        //缺陷类型下拉框赋值
        $.ajax({
            url:"/XunJianZhiXing/QueLeiXia",
            dataType: 'json',
            success: function(data) {
                if (data!== null) {
                    $("#service").empty();
                    $("#service").append(new Option("--请选择--", " "));
                    $.each(data, function(index, item) {
                        $('#service').append(new Option(item.configName,item.id));
                    });
                } else {
                    $("#service").append(new Option("暂无数据", ""));
                }
                //重新渲染
                form.render("select");
            }
        })
        $.ajax({
            url:"/XunJianZhiXing/ChaQueJi",
            dataType: 'json',
            success: function(data) {
                if (data!== null) {
                    $("#service2").empty();
                    $("#service2").append(new Option("--请选择--", " "));
                    $.each(data, function(index, item) {
                        $('#service2').append(new Option(item.configName,item.id));
                    });
                } else {
                    $("#service2").append(new Option("暂无数据", ""));
                }
                //重新渲染
                form.render("select");
            }
        })
        //查询按钮监听
        form.on('submit(user-query)', function(data) {
            console.log(data.field)
            table.reload('user-table', {
                where:data.field
            })
            return false;
        });

        //查询按钮监听
        table.on('tool(user-table)', function(data) {
            console.log(data);
            // console.log(data.field)
            let qxjb= $("#service4").val();
            alert(qxjb+"缺陷基本"+data.data.id)
            if (data.event === 'edit') {
                if(qxjb=="0"){
                    alert("请选择缺陷类型")
                    return;
                }
                alert("删除")
                $.ajax({
                    url:"/QuXianGuAnLi/QuXianDengJiBaoCun",
                    type:"post",
                    dataType: 'json',
                    data:{"id":data.data.id,"qxJb":qxjb},
                    success: function(data) {
                        alert(data.msg)
                        if(data.msg=="确认等级成功"){
                            layer.msg(data.msg,{icon:6})
                            layui.table.reload("user-table",{
                                    page:{
                                    curr: 1 //重新从第 1 页开始
                                 }
                            });
                        }else {
                            layer.msg(data.msg,{icon:5})
                        }
                    }
                })
                //重新渲染
                form.render("select");
            }
            table.reload('user-table', {
                where:data.field
            })
            return false;
        });
    });
</script>

</body>
</html>